#!/bin/bash
file=$1
tag=$2

line=`cat $file|grep 'image:.*:.*'|grep -v '^#'` # 筛选image:harbor.zts.com.cn/portal-web:2.1.0
src=`echo $line|awk -F ":" '{print $2":"$3}'` # harbor.zts.com.cn/portal-web:2.1.0
des=`echo $line|awk -F ":" '{print $2":"}'`$tag # 指定tag
echo "------------------------------------原镜像$src------------------------------------------"
echo "------------------------------------新镜像$des------------------------------------------"
sed -i "s#$src#$des#g" $file 

echo "-----------------------------------"
kubectl delete -f $file
sleep 3
echo "--------------------------------------------------------------------------------"
kubectl create -f $file
sleep 3
echo "-----------------------------------"


